<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
   	<title>分类汇总报表</title>
    <link href="../../rs/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="../../rs/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="../../rs/plugins/bootstrap_tab/css/bootstrap-table.css" rel="stylesheet">
    <link href="../../rs/css/animate.min.css" rel="stylesheet">
    <link href="../../rs/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="../../rs/plugins/datapicker/datepicker3.css" rel="stylesheet">
   
    <link href="../../rs/plugins/bootstrap_tab/css/plugins/chosen/chosen.css" rel="stylesheet">
    <?php require_once('login.php'); ?>
    <style>
        .input-daterange{width: 100%;}
        .m-b-xs{
            padding-right: 0px;
            padding-left: 0px;
        }
        .editable-click, a.editable-click, a.editable-click:hover {
            border-bottom: 0px;
        }
        .fixed-table-pagination .page-list{
            display: none;
        }
        .border0{border:0px}
    </style>

</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-content form-inline">
            <div class="col-sm-5 m-b-xs">
                <div class="form-group" id="data_5">
                    <div class="input-daterange input-group" id="datepicker">
                        <input style="height:34px" type="text" class="input-sm form-control" name="start" value="" id="start"/>
                        <span style="background: #E5E6E7;" class="input-group-addon">到</span>
                        <input style="height:34px" type="text" class="input-sm form-control" name="end" value="" id="end"/>
                       
                    </div>
                </div>
            </div>
          <div class="col-sm-4"  >
			<div class=" draggable">
				<div class="input-group ">
				<span class="input-group-btn">
					<button style="margin-right: -2px;height:34px;background-color: #FFF;border: 1px solid #e5e6e7;font-size: 14px" type="button" class="btn btn-sm ">门店</button>
				</span>
					<select style="width:300px" class="form-control chosen-select" id="mdbh" data-placeholder="选择门店"   multiple>
						 
					</select>
                    <span class="input-group-btn">
					<button style="margin-left: 10px;height:34px; border: 1px solid #e5e6e7;font-size: 14px" type="button" class="btn btn-sm " onclick="do_search()">执行</button>
				</span>
                   
				</div>
			</div>
		</div>        
            <div class="col-sm-2 m-b-xs">
            </div>
            <table id="table">
            </table>
            <!-- End Example Card View -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
<script src="../../rs/js/jquery.min.js"></script>
<script src="../../rs/js/bootstrap.js"></script>
<script src="../../rs/plugins/bootstrap_tab/js/bootstrap-table.min.js"></script>
<script src="../../rs/plugins/bootstrap_tab/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="../../rs/plugins/datapicker/bootstrap-datepicker.js"></script>
<script src="../../rs/plugins/bootstrap_tab/js/bootstrap-table-export.js"></script>
<script src="../../rs/plugins/bootstrap_tab/js/tableExport.js"></script>
<script src="../../rs/js/jquery.cookie.js"></script>
<script src="../../rs/js/common_qj.js"></script>
<script src="../../rs/js/store.min.js"></script>  <!-- 打印面单js -->
<script src="../../rs/plugins/layer/layer.min.js"></script>
<script src="../../rs/plugins/bootstrap_tab/js/plugins/chosen/chosen.jquery.js"></script>
<script type="text/javascript">
    var $table = $('#table');
    var sign=URLencode($.cookie('sign'));
    var shoplistdata;
    $("#data_5 .input-daterange").datepicker({keyboardNavigation: !1, forceParse: !1, autoclose: !0});
    $(function(){
        //获取门店数据
         queryMd();
        var start=(new Date(new Date()-0 - 7*86400000)).format( 'yyyy-MM-dd');
        var end=(new Date()).format( 'yyyy-MM-dd');
        $('#start').val(start);
        $('#end').val(end);
        $('#table').bootstrapTable({
             columns: [{field: 'rid',title: '产品编号'},{field: 'mc',title: '产品名称'}],       
             data:[],
            advancedSearch:true,
            clickToSelect:true,
            showExport:true,
            
        }); 
    });
  
    
 

    //标签多选
    var config = {
        ".chosen-select": {},
        ".chosen-select-deselect": {
            allow_single_deselect: !0
        },
        ".chosen-select-no-single": {
            disable_search_threshold: 10
        },
        ".chosen-select-no-results": {
            no_results_text: "Oops, nothing found!"
        },
        ".chosen-select-width": {
            width: "95%"
        }
    };
    for (var selector in config) $(selector).chosen(config[selector]);
        //select value获取
        function chose_get_value(select){
            return $(select).val();
        }
    //动态加载标签的值
    function queryMd(){
        $.ajax({
            type: "post",
            url:G_url+'Prsh/getshop?sign='+sign,
            data:'sign='+sign,
            dataType: "json",
            success: function (result){
                shoplistdata=result;
                var ff = result.rows;
                var html = '';
                $.each(ff, function (a, b) {//直接取出json的prolist做each循环.
                    html += "<option value='"+b.shopid+"'>" + b.shopname + "</option>";//拼接字符串.
                });
                $("#mdbh").append(html);
                $("#mdbh").trigger("chosen:updated");//更新下拉选项
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
            }
        });
    }



    function do_search(){
		var mdbh=chose_get_value('#mdbh');
        
      if(mdbh==null){
         layer.msg("请先选择门店！");
         return;
      }
		 
	     var obj=shoplistdata.rows;
		 var newdata=[{field: 'rid',title: '产品编号'},{field: 'mc',title: '产品名称'}];
	 
		 for (i=0;i<mdbh.length ;i++ ) { 
			 var ttt=mdbh[i];
			 for (n=0;n<obj.length ;n++ ) { 
			  if(ttt==obj[n].shopid){ 
				newdata.push({"field":obj[n].shopid,"title":obj[n].shopname});
				break;
					}
				} 

			} 
            
		var rq1=$("input[name='start']").val();
        var rq2=$("input[name='end']").val();
		layer.msg('数据加载中...', {icon: 16, time: 200000, shade: [0.1, 'black']});
		$.ajax({
			type: "post",
				url:G_url+'repoxs/slsthz'+"/"+rq1+"/"+rq2,
			data:'sign=' + sign,
			dataType: "json",
			success: function (result){
                 $('#table').bootstrapTable('destroy');
                 $('#table').bootstrapTable({
                     columns: newdata,
                     data: result.rows,
                     advancedSearch:true,
                     clickToSelect:true,
                     showExport:true,
                 }); 

				layer.closeAll();
			},
			error: function (XMLHttpRequest, textStatus, errorThrown) {
				//alert(errorThrown);
			}
		});
	}

</script>
</body>
</html>
